<?php getView('modules/header') ?>
	<div class="container">
		<div class="row">
			<div class="col-xs-10 col-xs-offset-1 col-sm-4 col-sm-offset-4">
				<a href="<?php echo base_url(); ?>" class="logo-login">
					<img src="<?php echo site_url('public/admin/images/wordpress-logo.svg'); ?>" alt="" class="img-responsive">
				</a>
			</div>
		</div>
		<div class="row">
			<div class="col-xs-12 col-sm-4 col-sm-offset-4">
				<?php 
				$attr = array('class' => 'form', 'id' => 'form-login');
				echo form_open('admin/login/checklogin',$attr);
				?>
					<h2 class="text-center">Log In</h2>
					<div class="form--group">
						<label for="username">Username</label>
						<input id="username" type="text" name="username" class="form-control">
					</div>
					<div class="form-group">
						<label for="password">Password</label>
						<input id="password" type="password" name="password" class="form-control">
					</div>
					<div class="form-group">
						<input type="submit" name="login-submit" id="login-submit" value="Log In" class="form-control btn btn-primary">
					</div>
					<div class="form-group">
						<p class="error"></p>
					</div>
					<div class="form-group">
						<a href="<?php echo site_url('admin/signup'); ?>" id="register">Register</a>
					</div>
				</form>
			</div>
		</div>
	</div>
<script>
	$(function(){
		// ----------------------------------------- Validate
		$('#form-login').validate({
			rules:{
				username: 'required',
				password: 'required'
			},
			messages:{
				username: "Enter your username",
				password: "Enter your password"
			}
		});
		// ----------------------------------------- Form submit
		$('#form-login').submit(function(){
			if($('#form-login').valid()){
				$.post($('#form-login').attr('action'), $('#form-login').serializeArray(), function(json){
					if(json.status == 0){
						showHide(json.message, 3000, '#form-login .error');
					}else{
						adminAlert(json.message, 3000, 'success');
						setTimeout(function(){
							window.location.href = 'dashboard';
						}, 3000);
					}
				},'json');
			}
			return false;
		});
	});
</script>
<div id="admin-alert"></div>
</body>
</html>